﻿import QtQuick 2.0
import QtQuick.Window 2.12
import "./components"
Window {
    id: root
    readonly property real dp: config.dp
    property var error_text: ""
    property var method_text: ""

    width: 600*dp
    height: 320*dp
    minimumHeight: 320*dp
    maximumHeight: 320*dp
    minimumWidth: 600*dp
    maximumWidth: 600*dp
    title: "故障"
    modality: Qt.WindowModal
    flags: Qt.Window | Qt.WindowTitleHint |Qt.WindowSystemMenuHint | Qt.WindowCloseButtonHint

    onVisibleChanged: {
        if(method_text==="是"){
            continueButton.visible=true
        }
        if(method_text==="否"){
            continueButton.visible=false
        }
    }

    Rectangle{
        width: parent.width-80*dp
        height: 130*dp
        x:40*dp
        y:20*dp
        color: "#FEF4F3"
        radius: 8
        border.color: "#E69393"
        Image {
            x:20*dp
            y:20*dp
            width: 23*dp
            height: 23*dp
            source: "qrc:/picture/gz_jg.png"
        }
        Text {
            x:60*dp
            y:20*dp
            height: 30*dp
            width: parent.width-50*dp
            text: qsTr("故障信息")
            font.bold: true
            font.pixelSize: config.pointsize + 2*dp
        }
        Text {
            x:20*dp
            y:60*dp
            height: 30*dp
            width: parent.width-40*dp
            text: error_text
            font.pixelSize: config.fontsize
        }
    }

    CustomButton{
        id:continueButton
        width: 120*dp
        x:295*dp
        y:218*dp
        title: "继续实验"
        defaultMode1:true
        onReleased: {
            CommunicationMethod.stopExperiment(7);
            close()
        }
    }

    PushButton{
        id:finishButton
        width: 120*dp
        x:method_text==="否"?230*dp:150*dp
        y:218*dp
        text_color: "black"
        button_color: "#FF9478"
        button_border : "transparent"
        button_color_press : "#FF9400"
        title: "停止实验"
        onReleased: {
            CommunicationMethod.stopExperiment(2);
        }
    }
    Connections{
        target: CSignal
        onExperimentStatus:{
            if(type=="2")//停止
            {
                if(status==0){
                    close()
                }
            }
        }
    }
}
